% fun = @(x)x.^2 - 3*x + exp(x) - 2;
% 
% fplot(fun,[-2,2]);
% [a,b,c] = fsolve(fun,0);

% clear;t=0:24;
% 
% c=[15 14 14 14 14 15 16 18 20 22 23 25 28 31 32 31 29 27 25 24 22 20 18 17 16];
% p = polyfit(t,c,2);
% plot(t,c);
% 
% d = fun(@(x)x^2 , 10 ,9);
% p = 5;
% fun = @(x) (1 - x).*sqrt(10.52 + x) ./ (x.* sqrt(1 + x) .* sqrt(p)) - 3.06;
% fplot(fun,[0,1]);
% r = fzero(fun,0.5);

% all_money = 7500 * 180;
% first_money = all_money * 0.3;
% k = 12 * 20;
% r = 5.04 /100 /12;
% a = (1 + r)^k * r *(all_money - first_money) / ( (1 + r)^k - 1);
% fprintf("%d",a);

% r=5.04/12/100;N=20*12;
% 
% x=7500*180 %房屋总价格
% 
% y=x*0.3 %首付款额
% 
% x0=x-y%贷款总额
% 
% a=(1+r)^N*r*x0/((1+r)^N-1)%月付还款额

% x = [0,4,10,12,15,22,28,34,40];
% y = [0,1,3,6,8,9,5,3,0];
% sum = 0;
% for i = 1 : length(x) - 1
%     sum = sum + (x(i + 1) - x(i)) * (y(i) + y(i + 1)) / 2;
% end
% fprintf("%d\n",sum);
% 
% trapz(x,y);
% 
% ret = gradient(y,x);
% fprintf("%d\n",ret);
clear; clc;
% t = 0 : 0.01 : 1.5;
% 
% x = log(cos(t));
% y = cos(t) - t.*sin(t);
% mm = gradient(y,x);
% 
% plot(x,mm);
% 
% [x_id,id] = min(abs(x + 1));
% ret = mm(id);

% 
% ret = integral(@(x)exp(-x).*sin(x.^3),1,inf);

% o = 0:0.01:pi/2;
% x = 2 * cos(o);
% y = 3 * sin(o);
% d = gradient(y,x);
% f = @(mode)sqrt(1 + fun(mode,x,d).^2);
% ff = integral(@(m)5*m,0,5);

% 
% a = 2;
% b = 3;
% 
% % 定义椭圆的参数方程
% o = 0:0.01:pi/2; % 参数从 0 到 pi/2
% x = a * cos(o);
% y = b * sin(o);
% 
% % 计算 dy/dx
% dydx = diff(y) ./ diff(x); % 计算导数的差分
% dydx = [dydx(1); dydx]; % 扩展到整个区间





ret = integral(@(x)fun(x),0,2);





